﻿using System;
using System.Reflection;
using System.Web.Mvc;

namespace RESTController.ActionFilters
{
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
    public class UseDeleteMethodAsConfiguredAttribute : ActionMethodSelectorAttribute
    {
        private readonly string deleteHttpMethod = RESTControllerSettings.Settings.DeleteHttpMethod;

        public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
        {
            string incomingVerb = controllerContext.HttpContext.Request.HttpMethod;
            return incomingVerb == deleteHttpMethod;            
        }
    }
}
